﻿
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title></title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.11.2.min.js" type="text/javascript"></script>


    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/JqueryPlug/dtGrid/jquery.dtGrid.js"></script>
    <script src="/Scripts/SZHLCommon.js"></script>
    <script src="/Scripts/city.js"></script>
    <!--[if IE]>
        <script src="../../Scripts/HTML5.js"></script>
    <![endif]-->
    <style type="text/css">
        .szhl_Upload {
            display: none;
        }

        .middle {
            line-height: 30px;
            vertical-align: middle;
            float: left;
            display: inline;
        }
    </style>
    <script type="text/javascript">

        var model = avalon.define({
            $id: "CompanyManager",
            CompanyData: { "QYName": "", "QYProfile": "", "ContactUser": "", "Position": "", "TelPhone": "", "Mobile": "", "Email": "", "Province": "", "City": "", "Address": "", "WebSite": "" },
            CompanyEdit: function () {
                var modelValue = JSON.stringify(model.CompanyData.$model);
                $.post("/API/SZHLAPI.ashx", { Action: "EDITCOMPANY", P1: modelValue },
                function (result) {

                    if ($.trim(result.ErrorMsg) != "") {
                        parent.ComFunJS.winwarning(result.ErrorMsg);
                    } else {
                        parent.ComFunJS.winsuccess("保存成功");
                    }
                });
            },
            UploadLoad: function (dom) {
                var form = new FormData();
                form.append("Action", "ComIco");
                form.append("file", $(dom).get(0).files[0]);
                var xhr = new XMLHttpRequest();
                xhr.open("post", '../../View/Common/UploadFiles.ashx', true);
                xhr.onload = function () {
                    // alert("上传完成!");
                };
                xhr.send(form);
                //$(dom).parent().find("img").prop("src", "/images/Log/SZHL.jpg?v=" + Math.random());
                //$(dom).parent().find("img").prop("src", "/images/Log/SZHL.jpg");
            }
            ,
            GetCity: function () {
                var province = $("#Province").val();
                $("#city option").remove();
                $(cities).each(function () {
                    var city = $(this);
                    if ($(this)[0] == province) {
                        $(city).each(function (i, val) {
                            if (i == 1 && model.CompanyData.City == "") {
                                model.CompanyData.City = val;
                            }
                            if (i > 0) {
                                $("#city").append("<option value=" + val + ">" + val + "</option>")
                            }
                        })
                    }
                })
            },
            SetFrameHeight: function (framename) {
                var oFrm = document.getElementById(framename);
                oFrm.onload = oFrm.onreadystatechange = function () {
                    if (this.readyState && this.readyState != 'complete') return;
                    else {
                        var mainheight = $("#dvContent").height() - 45;
                        $("#" + framename).height(mainheight);
                        $("#mastmenu").height(mainheight);
                        $(window.frames[framename].document).find(".maindiv").css({ height: mainheight + "px", overflow: "auto" });
                    }
                }
            }
        });
        avalon.ready(function () {
            $(cities).each(function () {
                $("#Province").append("<option value='" + $(this)[0] + "' >" + $(this)[0] + "</option>").change(function () {
                    model.GetCity();
                });
            })
            //获取主要菜单
            $.getJSON('/API/SZHLAPI.ashx?Action=GETCOMPANYINFO', function (resultData) {
                model.CompanyData = resultData.Result;
                $("#Province").val(model.CompanyData.$model.Province);
                model.GetCity();
                $("#city").val(model.CompanyData.$model.City);
            })
        })

    </script>
</head>
<body ms-controller="CompanyManager">
    <div class="container-fluid maindiv" style="margin: 20px">
        <div class="panel panel-default">
            <div class="panel-heading">企业信息</div>
            <div class="panel-body">
                <div class="form-horizontal" style="margin:20px  auto auto 50px; ">
                    <div class="form-group">
                        <label for="companyName" class=" col-xs-2 control-label text-right">企业名称</label>
                        <div class="col-xs-6">
                            <input type="text" class="form-control" id="companyName" ms-duplex="CompanyData.QYName" placeholder="请输入企业名称" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="ContactUser" class="col-xs-2 control-label text-right">企业联系人</label>
                        <div class="col-xs-6">
                            <input type="text" class="form-control" id="ContactUser" ms-duplex="CompanyData.ContactUser" placeholder="请输入企业联系人" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Position" class="col-xs-2 control-label text-right">职务</label>
                        <div class="col-xs-6">
                            <input type="text" class="form-control" id="Position" ms-duplex="CompanyData.Position" placeholder="请输入职务" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="TelPhone" class="col-xs-2 control-label text-right">公司电话</label>
                        <div class="col-xs-6">
                            <input type="text" class="form-control" id="TelPhone" ms-duplex="CompanyData.TelPhone" placeholder="请输入公司电话" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Mobile" class="col-xs-2 control-label text-right">移动电话</label>
                        <div class="col-xs-6">
                            <input type="text" class="form-control " id="Mobile" ms-duplex="CompanyData.Mobile" placeholder="请输入移动电话" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Email" class="col-xs-2 control-label text-right">电子邮件</label>
                        <div class="col-xs-6">
                            <input type="text" class="form-control" id="Email" ms-duplex="CompanyData.Email" placeholder="请输入电子邮件" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="Province" class="col-xs-2 control-label text-right">所在地区</label>
                        <div class="col-xs-2">
                            <select name="Province" id="Province" ms-duplex="CompanyData.Province" class="form-control">
                                <option value="">-请选择-</option>
                            </select>
                        </div>
                        <div class="col-xs-2">
                            <select name="city" id="city" ms-duplex="CompanyData.City" class=" form-control">
                                <option value="">-请选择省份-</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Address" class="col-xs-2 control-label text-right">地址</label>
                        <div class="col-xs-6">
                            <input type="text" class="form-control" ms-duplex="CompanyData.Address" id="Address" placeholder="请输入通讯地址" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="WebSite" class="col-xs-2 control-label text-right">企业Logo</label>
                        <div class="col-xs-6 text-left">
                            <img src="/images/Log/SZHL.jpg"  onerror="javascript: $(this).hide();" style="width:70px;height:70px; float:left" />
                            <input type="file" class="form-control p16" id="ComIco" style="float:left;width:80%; margin-top:35px;" name="ComIco" ms-change="UploadLoad(this)" />
                            <!--<a href="javascript:void(0);" class="btn btn-pd btn-primary p16">上传文件</a>-->
                        </div>
                    </div>
                    <div class="form-group">
                        <div class=" col-xs-8   text-center">
                            <input type="button" value="保 存" ms-click="CompanyEdit()" class="btn btn-success btn-lg" width="180px" />

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
